").clone().addClass('img_grayscale').css({"position":"absolute","z-index":"5","opacity":"0"}).insertBefore(el).queue(function(){
var el=jQuery(this);
el.parent().css({"width":this.width,"height":this.height});
el.dequeue();
});
this.src=grayscaleIE10(this.src);
});
jQuery("a.greyscaled img").on({
mouseenter: function (){
jQuery(this).parent().find('img:first').stop().animate({opacity:1}, 200);
},
mouseleave: function (){
jQuery('.img_grayscale').stop().animate({opacity:0}, 200);
}});
function grayscaleIE10(src){
var canvas=document.createElement('canvas');
var ctx=canvas.getContext('2d');
var imgObj=new Image();
imgObj.src=src;
canvas.width=imgObj.width;
canvas.height=imgObj.height;
ctx.drawImage(imgObj, 0, 0);
var imgPixels=ctx.getImageData(0, 0, canvas.width, canvas.height);
for(var y=0; y < imgPixels.height; y++){
for(var x=0; x < imgPixels.width; x++){
var i=(y * 4) * imgPixels.width + x * 4;
var avg=(imgPixels.data[i] + imgPixels.data[i + 1] + imgPixels.data[i + 2]) / 3;
imgPixels.data[i]=avg;
imgPixels.data[i + 1]=avg;
imgPixels.data[i + 2]=avg;
}}
ctx.putImageData(imgPixels, 0, 0, 0, 0, imgPixels.width, imgPixels.height);
return canvas.toDataURL();
};};
function getInternetExplorerVersion(){
var rv=-1;
if(navigator.appName=='Microsoft Internet Explorer'){
var ua=navigator.userAgent;
var re=new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
if(re.exec(ua)!=null)
rv=parseFloat(RegExp.$1);
}
else if(navigator.appName=='Netscape'){
var ua=navigator.userAgent;
var re=new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})");
if(re.exec(ua)!=null)
rv=parseFloat(RegExp.$1);
}
return rv;
};});
(function(a){function d(b){var c=b||window.event,d=[].slice.call(arguments,1),e=0,f=!0,g=0,h=0;return b=a.event.fix(c),b.type="mousewheel",c.wheelDelta&&(e=c.wheelDelta/120),c.detail&&(e=-c.detail/3),h=e,c.axis!==undefined&&c.axis===c.HORIZONTAL_AXIS&&(h=0,g=-1*e),c.wheelDeltaY!==undefined&&(h=c.wheelDeltaY/120),c.wheelDeltaX!==undefined&&(g=-1*c.wheelDeltaX/120),d.unshift(b,e,g,h),(a.event.dispatch||a.event.handle).apply(this,d)}var b=["DOMMouseScroll","mousewheel"];if(a.event.fixHooks)for(var c=b.length;c;)a.event.fixHooks[b[--c]]=a.event.mouseHooks;a.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var a=b.length;a;)this.addEventListener(b[--a],d,!1);else this.onmousewheel=d},teardown:function(){if(this.removeEventListener)for(var a=b.length;a;)this.removeEventListener(b[--a],d,!1);else this.onmousewheel=null}},a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})})(jQuery);
(function($){
'use strict';
var TUBEPLAYER=".tubeplayer",
TUBEPLAYER_CLASS="jquery-youtube-tubeplayer",
OPTS="opts" + TUBEPLAYER;
var TP={
inited: false,
ytplayers: {},
inits: [],
iframeScriptInited: false,
State: {
'UNSTARTED': -1,
'ENDED': 0,
'PLAYING': 1,
'PAUSED': 2,
'BUFFERING': 3,
'CUED': 5
},
Error: {
'BAD_INIT': 0,
'INVALID_PARAM': 2,
'NOT_FOUND': 100,
'NOT_EMBEDDABLE': 101,
'CANT_PLAY': 150
}};
$.tubeplayer={
events: {},
TubePlayer: TP
};
$.tubeplayer.defaults={
afterReady: function(){},
stateChange: function(player){
var _ret=this.onPlayer;
return function(state){
var _player=$('#'+player).parent();
if(typeof(state)==="object"){
state=state.data;
}
switch (state){
case TP.State.UNSTARTED:
return _ret.unstarted[player].call(_player);
case TP.State.ENDED:
return _ret.ended[player].call(_player);
case TP.State.PLAYING:
return _ret.playing[player].call(_player);
case TP.State.PAUSED:
return _ret.paused[player].call(_player);
case TP.State.BUFFERING:
return _ret.buffering[player].call(_player);
case TP.State.CUED:
return _ret.cued[player].call(_player);
default:
return null;
}};},
onError: function(player){
var _ret=this.onErr;
return function(errorCode){
var _player=$('#'+player).parent();
if(typeof(errorCode)==="object"){
errorCode=errorCode.data;
}
switch (errorCode){
case TP.Error.BAD_INIT:
case TP.Error.INVALID_PARAM:
return _ret.invalidParameter[player].call(_player);
case TP.Error.NOT_FOUND:
return _ret.notFound[player].call(_player);
case TP.Error.NOT_EMBEDDABLE:
case TP.Error.CANT_PLAY:
return _ret.notEmbeddable[player].call(_player);
default:
return _ret.defaultError[player].call(_player);
}};},
qualityChange: function(player){
var _this=this;
return function(suggested){
var _player=$('#'+player).parent();
if(typeof(suggested)==="object"){
suggested=suggested.data;
}
return _this.onQualityChange[player].call(_player, suggested);
};},
onQualityChange: {},
onPlayer: {
unstarted: {},
ended: {},
playing: {},
paused: {},
buffering: {},
cued: {}},
onErr: {
defaultError: {},
notFound: {},
notEmbeddable: {},
invalidParameter: {}}
};
var defaults={
width: 425,
height: 355,
allowFullScreen: "true",
initialVideo: "DkoeNLuMbcI",
start: 0,
preferredQuality: "auto",
showControls: false,
showRelated: false,
playsinline: false,
annotations: true,
autoPlay: false,
autoHide: true,
loop: 0,
theme: 'dark',
color: 'red',
showinfo: false,
modestbranding: true,
protocol: 'http',
wmode: 'transparent',
swfobjectURL: "ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js",
loadSWFObject: false,
allowScriptAccess: "always",
playerID: "tubeplayer-player-container",
iframed: true,
onPlay: function(){},
onPause: function(){},
onStop: function(){},
onSeek: function(){},
onMute: function(){},
onUnMute: function(){},
onPlayerUnstarted: function(){},
onPlayerEnded: function(){},
onPlayerPlaying: function(){},
onPlayerPaused: function(){},
onPlayerBuffering: function(){},
onPlayerCued: function(){},
onQualityChange: function(){},
onError: function(){},
onErrorNotFound: function(){},
onErrorNotEmbeddable: function(){},
onErrorInvalidParameter: function(){}};
$.fn.tubeplayer=function(input, xtra){
var $this=$(this);
var type=typeof input;
if(arguments.length===0||type==="object"){
return $this.each(function(){
TP.init($(this), input);
});
}else if(type==="string"){
return $this.triggerHandler(input + TUBEPLAYER, (typeof xtra!=='undefined' ? xtra:null));
}};
var wrap_fn=function(fn){
return function(evt, param){
var p=TP.getPkg(evt);
if(p.ytplayer){
var ret=fn(evt, param, p);
if(typeof(ret)==="undefined"){
ret=p.$player;
}
return ret;
}
return p.$player;
};};
$.tubeplayer.getPlayers=function(){
return TP.ytplayers;
};
TP.init=function($player, opts){
if($player.hasClass(TUBEPLAYER_CLASS)) return $player;
var o=$.extend({}, defaults, opts);
o.playerID +="-" + guid();
$player.addClass(TUBEPLAYER_CLASS).data(OPTS, o);
for (var event in PLAYER)
$player.bind(event + TUBEPLAYER, $player, PLAYER[event]);
TP.initDefaults($.tubeplayer.defaults, o);
$("
").attr("id", o.playerID).appendTo($player);
TP.initPlayer($player, o);
return $player;
};
TP.getPkg=function(evt){
var $player=evt.data;
var opts=$player.data(OPTS);
var ytplayer=TP.ytplayers[opts.playerID];
return {
$player: $player,
opts: opts,
ytplayer: ytplayer
};};
TP.iframeReady=function(o){
TP.inits.push(function(){
new YT.Player(o.playerID, {
videoId: o.initialVideo,
width: o.width,
height: o.height,
playerVars: {
'autoplay': (o.autoPlay ? 1:0),
'autohide': (o.autoHide ? 1:0),
'controls': (o.showControls ? 1:0),
'loop': (o.loop ? 1:0),
'playlist': (o.loop ? o.initialVideo:""),
'rel': (o.showRelated ? 1:0),
'fs': (o.allowFullScreen ? 1:0),
'wmode': o.wmode,
'showinfo': (o.showinfo ? 1:0),
'modestbranding': (o.modestbranding ? 1:0),
'iv_load_policy': (o.annotations ? 1:3),
'start': o.start,
'theme': o.theme,
'color': o.color,
'playsinline': o.playsinline
},
events: {
'onReady': function(evt){
TP.ytplayers[o.playerID]=evt.target;
var $player=$(evt.target.getIframe()).parents("." + TUBEPLAYER_CLASS);
$.tubeplayer.defaults.afterReady($player);
},
'onPlaybackQualityChange': $.tubeplayer.defaults.qualityChange(o.playerID),
'onStateChange': $.tubeplayer.defaults.stateChange(o.playerID),
'onError': $.tubeplayer.defaults.onError(o.playerID)
}});
});
if(TP.inits.length >=1&&!TP.inited){
return function(){
for (var i=0; i < TP.inits.length; i++){
TP.inits[i]();
}
TP.inited=true;
};}
if(TP.inited){
(TP.inits.pop())();
}
return window.onYouTubePlayerAPIReady;
};
TP.initDefaults=function(d, o){
var ID=o.playerID;
var dp=d.onPlayer;
dp.unstarted[ID]=o.onPlayerUnstarted;
dp.ended[ID]=o.onPlayerEnded;
dp.playing[ID]=o.onPlayerPlaying;
dp.paused[ID]=o.onPlayerPaused;
dp.buffering[ID]=o.onPlayerBuffering;
dp.cued[ID]=o.onPlayerCued;
d.onQualityChange[ID]=o.onQualityChange;
var de=d.onErr;
de.defaultError[ID]=o.onError;
de.notFound[ID]=o.onErrorNotFound;
de.notEmbeddable[ID]=o.onErrorNotEmbeddable;
de.invalidParameter[ID]=o.onErrorInvalidParameter;
};
TP.initPlayer=function($player, o){
if(o.iframed) TP.initIframePlayer($player, o);
else TP.initFlashPlayer($player, o);
};
TP.initIframePlayer=function($player, o){
if(!TP.iframeScriptInited){
var tag=document.createElement('script');
tag.src=o.protocol + "://www.youtube.com/iframe_api";
var firstScriptTag=document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
TP.iframeScriptInited=true;
}
window.onYouTubePlayerAPIReady=TP.iframeReady(o);
};
TP.initFlashPlayer=function($player, o){
if(o.loadSWFObject){
o.swfobjectURL=o.swfobjectURL.replace('http://', '');
o.swfobjectURL=o.swfobjectURL.replace('https://', '');
o.swfobjectURL=o.protocol + '://' + o.swfobjectURL;
$.getScript(o.swfobjectURL, TP.init_flash_player(o));
}else{
TP.init_flash_player(o)();
}};
TP.init_flash_player=function(o){
return function(){
if(!window.swfobject){
alert("YouTube Player couldn't be initialized. Please include swfobject.");
return;
}
function onYouTubeIframeAPIReady(){
player=new YT.Player(o.playerID, {
height: o.height,
width: o.width,
videoId: o.initialVideo,
playerVars: {
'autoplay': (o.autoPlay ? 1:0),
'controls': (o.showControls ? 1:0),
'autohide': (o.autoHide ? 1:0),
'showinfo': (o.showinfo ? 1:0),
'modestbranding': (o.modestbranding ? 1:0),
'loop': (o.loop ? 1:0),
'rel': (o.showRelated ? 1:0),
'hd': 1,
'wmode': 'opaque'
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}});
}
var url=["//www.youtube.com/embed/"];
url.push(o.initialVideo);
url.push("?&enablejsapi=1&version=3");
url.push("&playerapiid=" + o.playerID);
url.push("&rel=" + (o.showRelated ? 1:0));
url.push("&autoplay=" + (o.autoPlay ? 1:0));
url.push("&autohide=" + (o.autoHide ? 1:0));
url.push("&loop=" + (o.loop ? 1:0));
url.push("&playlist=" + (o.loop ? o.initialVideo:""));
url.push("&controls=" + (o.showControls ? 1:0));
url.push("&showinfo=" + (o.showinfo ? 1:0));
url.push("&modestbranding=" + (o.modestbranding ? 1:0));
url.push("&iv_load_policy=" + (o.annotations ? 1:3));
url.push("&start=" + o.start);
url.push("&theme=" + o.theme);
url.push("&color=" + o.color);
url.push("&playsinline=" + o.playsinline);
url.push("&fs=" + (o.allowFullScreen ? 1:0));
window.onYouTubePlayerReady=function(playerId){
var player=document.getElementById(playerId);
var pid=playerId.replace(/-/g, '');
var d=$.tubeplayer.defaults;
$.tubeplayer.events[pid]={
"stateChange": d.stateChange(playerId),
"error": d.onError(playerId),
"qualityChange": d.qualityChange(playerId)
};
player.addEventListener("onStateChange", "$.tubeplayer.events." + pid + ".stateChange");
player.addEventListener("onError", "$.tubeplayer.events." + pid + ".error");
player.addEventListener("onPlaybackQualityChange", "$.tubeplayer.events." + pid + ".qualityChange");
TP.ytplayers[playerId]=player;
var $player=$(player).parents("." + TUBEPLAYER_CLASS);
$.tubeplayer.defaults.afterReady($player);
};};
};
TP.getVideoIDFromURL=function(sURL){
sURL=sURL||"";
var qryParamsStart=sURL.indexOf("?");
var qryParams=sURL.substring(qryParamsStart, sURL.length);
var videoStart=qryParams.indexOf("v=");
if(videoStart > -1){
var videoEnd=qryParams.indexOf("&", videoStart);
if(videoEnd===-1){
videoEnd=qryParams.length;
}
return qryParams.substring(videoStart + "v=".length, videoEnd);
}
return "";
};
var PLAYER={
opts: wrap_fn(function(evt,param,p){
return p.opts;
}),
cue: wrap_fn(function(evt, param, p){
p.ytplayer.cueVideoById(param, 0, p.opts.preferredQuality);
}),
play: wrap_fn(function(evt, param, p){
if(typeof(param)==='object') p.ytplayer.loadVideoById({videoId: param.id, startSeconds: param.time, suggestedQuality: p.opts.preferredQuality });
else if(typeof param!=='undefined') p.ytplayer.loadVideoById({videoId: param, startSeconds: 0, suggestedQuality: p.opts.preferredQuality });
else p.ytplayer.playVideo();
p.opts.onPlay(param);
}),
pause: wrap_fn(function(evt, param, p){
p.ytplayer.pauseVideo();
p.opts.onPause(p);
}),
stop: wrap_fn(function(evt, param, p){
p.ytplayer.stopVideo();
p.opts.onStop(p);
}),
seek: wrap_fn(function(evt, param, p){
if(/:/.test(param)){
var parts=param.split(":").reverse();
param=0;
for (var i=0; i < parts.length; i++){
param +=Math.pow(60, i) * (parts[i] | 0);
}}
p.ytplayer.seekTo(param, true);
p.opts.onSeek(param);
}),
mute: wrap_fn(function(evt, param, p){
p.$player.attr("data-prev-mute-volume", p.ytplayer.getVolume());
p.ytplayer.mute();
p.opts.onMute(p);
}),
unmute: wrap_fn(function(evt, param, p){
p.ytplayer.unMute();
p.ytplayer.setVolume((p.$player.attr("data-prev-mute-volume")||50));
p.opts.onUnMute();
}),
isMuted: wrap_fn(function(evt, param, p){
return p.ytplayer.isMuted();
}),
volume: wrap_fn(function(evt, param, p){
if(typeof param!=='undefined'){
p.ytplayer.setVolume(param);
p.$player.attr("data-prev-mute-volume", p.ytplayer.getVolume());
}else{
return p.ytplayer.getVolume()||0;
}}),
quality: wrap_fn(function(evt, param, p){
if(typeof param!=='undefined') p.ytplayer.setPlaybackQuality(param);
else return p.ytplayer.getPlaybackQuality();
}),
playbackRate: wrap_fn(function(evt, param, p){
if(typeof param!=="undefined") p.ytplayer.setPlaybackRate(param);
else return p.ytplayer.getPlaybackRate();
}),
data: wrap_fn(function(evt, param, p){
var ret={};
var P=p.ytplayer;
ret.videoLoadedFraction=P.getVideoLoadedFraction();
ret.bytesLoaded=P.getVideoBytesLoaded();
ret.bytesTotal=P.getVideoBytesTotal();
ret.startBytes=P.getVideoStartBytes();
ret.state=P.getPlayerState();
ret.currentTime=P.getCurrentTime();
ret.duration=P.getDuration();
ret.videoURL=P.getVideoUrl();
ret.videoEmbedCode=P.getVideoEmbedCode();
ret.videoID=TP.getVideoIDFromURL(ret.videoURL);
ret.availableQualityLevels=P.getAvailableQualityLevels();
ret.availablePlaybackRates=P.getAvailablePlaybackRates();
return ret;
}),
videoId: wrap_fn(function(evt, param, p){
return TP.getVideoIDFromURL(p.ytplayer.getVideoUrl());
}),
size: wrap_fn(function(evt, param, p){
if(typeof param!=='undefined'&¶m.width&¶m.height){
p.ytplayer.setSize(param.width, param.height);
$(p.ytplayer).css(param);
}}),
destroy: wrap_fn(function(evt, param, p){
p.$player.removeClass(TUBEPLAYER_CLASS).data(OPTS, null).unbind(TUBEPLAYER).html("");
delete TP.ytplayers[p.opts.playerID];
var d=$.tubeplayer.defaults;
var events=['unstarted', 'ended', 'playing', 'paused', 'buffering', 'cued'];
$.each(events, function(i, event){
delete d.onPlayer[event][p.opts.playerID];
});
events=['defaultError', 'notFound', 'notEmbeddable', 'invalidParameter'];
$.each(events, function(i, event){
delete d.onErr[event][p.opts.playerID];
});
delete d.onQualityChange[p.opts.playerID];
delete $.tubeplayer.events[p.opts.playerID];
if('destroy' in p.ytplayer){
p.ytplayer.destroy();
}
$(p.ytplayer).remove();
return null;
}),
player: wrap_fn(function(evt, param, p){
return p.ytplayer;
})
};
function guid(){
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c){
var r=Math.random() * 16 | 0, v=c=='x' ? r:(r & 0x3 | 0x8);
return v.toString(16);
});
}})(jQuery);
(function(window, doc){
var m=Math,
dummyStyle=doc.createElement('div').style,
vendor=(function (){
var vendors='t,webkitT,MozT,msT,OT'.split(','),
t,
i=0,
l=vendors.length;
for(; i < l; i++){
t=vendors[i] + 'ransform';
if(t in dummyStyle){
return vendors[i].substr(0, vendors[i].length - 1);
}}
return false;
})(),
cssVendor=vendor ? '-' + vendor.toLowerCase() + '-':'',
transform=prefixStyle('transform'),
transitionProperty=prefixStyle('transitionProperty'),
transitionDuration=prefixStyle('transitionDuration'),
transformOrigin=prefixStyle('transformOrigin'),
transitionTimingFunction=prefixStyle('transitionTimingFunction'),
transitionDelay=prefixStyle('transitionDelay'),
isAndroid=(/android/gi).test(navigator.appVersion),
isIDevice=(/iphone|ipad/gi).test(navigator.appVersion),
isTouchPad=(/hp-tablet/gi).test(navigator.appVersion),
has3d=prefixStyle('perspective') in dummyStyle,
hasTouch='ontouchstart' in window&&!isTouchPad,
hasTransform=vendor!==false,
hasTransitionEnd=prefixStyle('transition') in dummyStyle,
RESIZE_EV='onorientationchange' in window ? 'orientationchange':'resize',
START_EV=hasTouch ? 'touchstart':'mousedown',
MOVE_EV=hasTouch ? 'touchmove':'mousemove',
END_EV=hasTouch ? 'touchend':'mouseup',
CANCEL_EV=hasTouch ? 'touchcancel':'mouseup',
TRNEND_EV=(function (){
if(vendor===false) return false;
var transitionEnd={
'':'transitionend',
'webkit':'webkitTransitionEnd',
'Moz':'transitionend',
'O':'otransitionend',
'ms':'MSTransitionEnd'
};
return transitionEnd[vendor];
})(),
nextFrame=(function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function(callback){ return setTimeout(callback, 1); };})(),
cancelFrame=(function (){
return window.cancelRequestAnimationFrame ||
window.webkitCancelAnimationFrame ||
window.webkitCancelRequestAnimationFrame ||
window.mozCancelRequestAnimationFrame ||
window.oCancelRequestAnimationFrame ||
window.msCancelRequestAnimationFrame ||
clearTimeout;
})(),
translateZ=has3d ? ' translateZ(0)':'',
iScroll=function (el, options){
var that=this,
i;
that.wrapper=typeof el=='object' ? el:doc.getElementById(el);
that.wrapper.style.overflow='hidden';
that.scroller=that.wrapper.children[0];
that.options={
hScroll: true,
vScroll: true,
x: 0,
y: 0,
bounce: true,
bounceLock: false,
momentum: true,
lockDirection: true,
useTransform: true,
useTransition: false,
topOffset: 0,
checkDOMChanges: false,
handleClick: true,
hScrollbar: true,
vScrollbar: true,
fixedScrollbar: isAndroid,
hideScrollbar: isIDevice,
fadeScrollbar: isIDevice&&has3d,
scrollbarClass: '',
zoom: false,
zoomMin: 1,
zoomMax: 4,
doubleTapZoom: 2,
wheelAction: 'scroll',
snap: false,
snapThreshold: 1,
onRefresh: null,
onBeforeScrollStart: function (e){ e.preventDefault(); },
onScrollStart: null,
onBeforeScrollMove: null,
onScrollMove: null,
onBeforeScrollEnd: null,
onScrollEnd: null,
onTouchEnd: null,
onDestroy: null,
onZoomStart: null,
onZoom: null,
onZoomEnd: null
};
for (i in options) that.options[i]=options[i];
that.x=that.options.x;
that.y=that.options.y;
that.options.useTransform=hasTransform&&that.options.useTransform;
that.options.hScrollbar=that.options.hScroll&&that.options.hScrollbar;
that.options.vScrollbar=that.options.vScroll&&that.options.vScrollbar;
that.options.zoom=that.options.useTransform&&that.options.zoom;
that.options.useTransition=hasTransitionEnd&&that.options.useTransition;
if(that.options.zoom&&isAndroid){
translateZ='';
}
that.scroller.style[transitionProperty]=that.options.useTransform ? cssVendor + 'transform':'top left';
that.scroller.style[transitionDuration]='0';
that.scroller.style[transformOrigin]='0 0';
if(that.options.useTransition) that.scroller.style[transitionTimingFunction]='cubic-bezier(0.33,0.66,0.66,1)';
if(that.options.useTransform) that.scroller.style[transform]='translate(' + that.x + 'px,' + that.y + 'px)' + translateZ;
else that.scroller.style.cssText +=';position:absolute;top:' + that.y + 'px;left:' + that.x + 'px';
if(that.options.useTransition) that.options.fixedScrollbar=true;
that.refresh();
that._bind(RESIZE_EV, window);
that._bind(START_EV);
if(!hasTouch){
if(that.options.wheelAction!='none'){
that._bind('DOMMouseScroll');
that._bind('mousewheel');
}}
if(that.options.checkDOMChanges) that.checkDOMTime=setInterval(function (){
that._checkDOMChanges();
}, 500);
};
iScroll.prototype={
enabled: true,
x: 0,
y: 0,
steps: [],
scale: 1,
currPageX: 0, currPageY: 0,
pagesX: [], pagesY: [],
aniTime: null,
wheelZoomCount: 0,
handleEvent: function (e){
var that=this;
switch(e.type){
case START_EV:
if(!hasTouch&&e.button!==0) return;
that._start(e);
break;
case MOVE_EV: that._move(e); break;
case END_EV:
case CANCEL_EV: that._end(e); break;
case RESIZE_EV: that._resize(); break;
case 'DOMMouseScroll': case 'mousewheel': that._wheel(e); break;
case TRNEND_EV: that._transitionEnd(e); break;
}},
_checkDOMChanges: function (){
if(this.moved||this.zoomed||this.animating ||
(this.scrollerW==this.scroller.offsetWidth * this.scale&&this.scrollerH==this.scroller.offsetHeight * this.scale)) return;
this.refresh();
},
_scrollbar: function (dir){
var that=this,
bar;
if(!that[dir + 'Scrollbar']){
if(that[dir + 'ScrollbarWrapper']){
if(hasTransform) that[dir + 'ScrollbarIndicator'].style[transform]='';
that[dir + 'ScrollbarWrapper'].parentNode.removeChild(that[dir + 'ScrollbarWrapper']);
that[dir + 'ScrollbarWrapper']=null;
that[dir + 'ScrollbarIndicator']=null;
}
return;
}
if(!that[dir + 'ScrollbarWrapper']){
bar=doc.createElement('div');
if(that.options.scrollbarClass) bar.className=that.options.scrollbarClass + dir.toUpperCase();
else bar.style.cssText='position:absolute;z-index:100;' + (dir=='h' ? 'height:7px;bottom:1px;left:2px;right:' + (that.vScrollbar ? '7':'2') + 'px':'width:7px;bottom:' + (that.hScrollbar ? '7':'2') + 'px;top:2px;right:1px');
bar.style.cssText +=';pointer-events:none;' + cssVendor + 'transition-property:opacity;' + cssVendor + 'transition-duration:' + (that.options.fadeScrollbar ? '350ms':'0') + ';overflow:hidden;opacity:' + (that.options.hideScrollbar ? '0':'1');
that.wrapper.appendChild(bar);
that[dir + 'ScrollbarWrapper']=bar;
bar=doc.createElement('div');
if(!that.options.scrollbarClass){
bar.style.cssText='position:absolute;z-index:100;background:rgba(0,0,0,0.5);border:1px solid rgba(255,255,255,0.9);' + cssVendor + 'background-clip:padding-box;' + cssVendor + 'box-sizing:border-box;' + (dir=='h' ? 'height:100%':'width:100%') + ';' + cssVendor + 'border-radius:3px;border-radius:3px';
}
bar.style.cssText +=';pointer-events:none;' + cssVendor + 'transition-property:' + cssVendor + 'transform;' + cssVendor + 'transition-timing-function:cubic-bezier(0.33,0.66,0.66,1);' + cssVendor + 'transition-duration:0;' + cssVendor + 'transform: translate(0,0)' + translateZ;
if(that.options.useTransition) bar.style.cssText +=';' + cssVendor + 'transition-timing-function:cubic-bezier(0.33,0.66,0.66,1)';
that[dir + 'ScrollbarWrapper'].appendChild(bar);
that[dir + 'ScrollbarIndicator']=bar;
}
if(dir=='h'){
that.hScrollbarSize=that.hScrollbarWrapper.clientWidth;
that.hScrollbarIndicatorSize=m.max(m.round(that.hScrollbarSize * that.hScrollbarSize / that.scrollerW), 8);
that.hScrollbarIndicator.style.width=that.hScrollbarIndicatorSize + 'px';
that.hScrollbarMaxScroll=that.hScrollbarSize - that.hScrollbarIndicatorSize;
that.hScrollbarProp=that.hScrollbarMaxScroll / that.maxScrollX;
}else{
that.vScrollbarSize=that.vScrollbarWrapper.clientHeight;
that.vScrollbarIndicatorSize=m.max(m.round(that.vScrollbarSize * that.vScrollbarSize / that.scrollerH), 8);
that.vScrollbarIndicator.style.height=that.vScrollbarIndicatorSize + 'px';
that.vScrollbarMaxScroll=that.vScrollbarSize - that.vScrollbarIndicatorSize;
that.vScrollbarProp=that.vScrollbarMaxScroll / that.maxScrollY;
}
that._scrollbarPos(dir, true);
},
_resize: function (){
var that=this;
setTimeout(function (){ that.refresh(); }, isAndroid ? 200:0);
},
_pos: function (x, y){
if(this.zoomed) return;
x=this.hScroll ? x:0;
y=this.vScroll ? y:0;
if(this.options.useTransform){
this.scroller.style[transform]='translate(' + x + 'px,' + y + 'px) scale(' + this.scale + ')' + translateZ;
}else{
x=m.round(x);
y=m.round(y);
this.scroller.style.left=x + 'px';
this.scroller.style.top=y + 'px';
}
this.x=x;
this.y=y;
this._scrollbarPos('h');
this._scrollbarPos('v');
},
_scrollbarPos: function (dir, hidden){
var that=this,
pos=dir=='h' ? that.x:that.y,
size;
if(!that[dir + 'Scrollbar']) return;
pos=that[dir + 'ScrollbarProp'] * pos;
if(pos < 0){
if(!that.options.fixedScrollbar){
size=that[dir + 'ScrollbarIndicatorSize'] + m.round(pos * 3);
if(size < 8) size=8;
that[dir + 'ScrollbarIndicator'].style[dir=='h' ? 'width':'height']=size + 'px';
}
pos=0;
}else if(pos > that[dir + 'ScrollbarMaxScroll']){
if(!that.options.fixedScrollbar){
size=that[dir + 'ScrollbarIndicatorSize'] - m.round((pos - that[dir + 'ScrollbarMaxScroll']) * 3);
if(size < 8) size=8;
that[dir + 'ScrollbarIndicator'].style[dir=='h' ? 'width':'height']=size + 'px';
pos=that[dir + 'ScrollbarMaxScroll'] + (that[dir + 'ScrollbarIndicatorSize'] - size);
}else{
pos=that[dir + 'ScrollbarMaxScroll'];
}}
that[dir + 'ScrollbarWrapper'].style[transitionDelay]='0';
that[dir + 'ScrollbarWrapper'].style.opacity=hidden&&that.options.hideScrollbar ? '0':'1';
that[dir + 'ScrollbarIndicator'].style[transform]='translate(' + (dir=='h' ? pos + 'px,0)':'0,' + pos + 'px)') + translateZ;
},
_start: function (e){
var that=this,
point=hasTouch ? e.touches[0]:e,
matrix, x, y,
c1, c2;
if(!that.enabled) return;
if(that.options.onBeforeScrollStart) that.options.onBeforeScrollStart.call(that, e);
if(that.options.useTransition||that.options.zoom) that._transitionTime(0);
that.moved=false;
that.animating=false;
that.zoomed=false;
that.distX=0;
that.distY=0;
that.absDistX=0;
that.absDistY=0;
that.dirX=0;
that.dirY=0;
if(that.options.zoom&&hasTouch&&e.touches.length > 1){
c1=m.abs(e.touches[0].pageX-e.touches[1].pageX);
c2=m.abs(e.touches[0].pageY-e.touches[1].pageY);
that.touchesDistStart=m.sqrt(c1 * c1 + c2 * c2);
that.originX=m.abs(e.touches[0].pageX + e.touches[1].pageX - that.wrapperOffsetLeft * 2) / 2 - that.x;
that.originY=m.abs(e.touches[0].pageY + e.touches[1].pageY - that.wrapperOffsetTop * 2) / 2 - that.y;
if(that.options.onZoomStart) that.options.onZoomStart.call(that, e);
}
if(that.options.momentum){
if(that.options.useTransform){
matrix=getComputedStyle(that.scroller, null)[transform].replace(/[^0-9\-.,]/g, '').split(',');
x=+(matrix[12]||matrix[4]);
y=+(matrix[13]||matrix[5]);
}else{
x=+getComputedStyle(that.scroller, null).left.replace(/[^0-9-]/g, '');
y=+getComputedStyle(that.scroller, null).top.replace(/[^0-9-]/g, '');
}
if(x!=that.x||y!=that.y){
if(that.options.useTransition) that._unbind(TRNEND_EV);
else cancelFrame(that.aniTime);
that.steps=[];
that._pos(x, y);
if(that.options.onScrollEnd) that.options.onScrollEnd.call(that);
}}
that.absStartX=that.x;
that.absStartY=that.y;
that.startX=that.x;
that.startY=that.y;
that.pointX=point.pageX;
that.pointY=point.pageY;
that.startTime=e.timeStamp||Date.now();
if(that.options.onScrollStart) that.options.onScrollStart.call(that, e);
that._bind(MOVE_EV, window);
that._bind(END_EV, window);
that._bind(CANCEL_EV, window);
},
_move: function (e){
var that=this,
point=hasTouch ? e.touches[0]:e,
deltaX=point.pageX - that.pointX,
deltaY=point.pageY - that.pointY,
newX=that.x + deltaX,
newY=that.y + deltaY,
c1, c2, scale,
timestamp=e.timeStamp||Date.now();
if(that.options.onBeforeScrollMove) that.options.onBeforeScrollMove.call(that, e);
if(that.options.zoom&&hasTouch&&e.touches.length > 1){
c1=m.abs(e.touches[0].pageX - e.touches[1].pageX);
c2=m.abs(e.touches[0].pageY - e.touches[1].pageY);
that.touchesDist=m.sqrt(c1*c1+c2*c2);
that.zoomed=true;
scale=1 / that.touchesDistStart * that.touchesDist * this.scale;
if(scale < that.options.zoomMin) scale=0.5 * that.options.zoomMin * Math.pow(2.0, scale / that.options.zoomMin);
else if(scale > that.options.zoomMax) scale=2.0 * that.options.zoomMax * Math.pow(0.5, that.options.zoomMax / scale);
that.lastScale=scale / this.scale;
newX=this.originX - this.originX * that.lastScale + this.x,
newY=this.originY - this.originY * that.lastScale + this.y;
this.scroller.style[transform]='translate(' + newX + 'px,' + newY + 'px) scale(' + scale + ')' + translateZ;
if(that.options.onZoom) that.options.onZoom.call(that, e);
return;
}
that.pointX=point.pageX;
that.pointY=point.pageY;
if(newX > 0||newX < that.maxScrollX){
newX=that.options.bounce ? that.x + (deltaX / 2):newX >=0||that.maxScrollX >=0 ? 0:that.maxScrollX;
}
if(newY > that.minScrollY||newY < that.maxScrollY){
newY=that.options.bounce ? that.y + (deltaY / 2):newY >=that.minScrollY||that.maxScrollY >=0 ? that.minScrollY:that.maxScrollY;
}
that.distX +=deltaX;
that.distY +=deltaY;
that.absDistX=m.abs(that.distX);
that.absDistY=m.abs(that.distY);
if(that.absDistX < 6&&that.absDistY < 6){
return;
}
if(that.options.lockDirection){
if(that.absDistX > that.absDistY + 5){
newY=that.y;
deltaY=0;
}else if(that.absDistY > that.absDistX + 5){
newX=that.x;
deltaX=0;
}}
that.moved=true;
that._pos(newX, newY);
that.dirX=deltaX > 0 ? -1:deltaX < 0 ? 1:0;
that.dirY=deltaY > 0 ? -1:deltaY < 0 ? 1:0;
if(timestamp - that.startTime > 300){
that.startTime=timestamp;
that.startX=that.x;
that.startY=that.y;
}
if(that.options.onScrollMove) that.options.onScrollMove.call(that, e);
},
_end: function (e){
if(hasTouch&&e.touches.length!==0) return;
var that=this,
point=hasTouch ? e.changedTouches[0]:e,
target, ev,
momentumX={ dist:0, time:0 },
momentumY={ dist:0, time:0 },
duration=(e.timeStamp||Date.now()) - that.startTime,
newPosX=that.x,
newPosY=that.y,
distX, distY,
newDuration,
snap,
scale;
that._unbind(MOVE_EV, window);
that._unbind(END_EV, window);
that._unbind(CANCEL_EV, window);
if(that.options.onBeforeScrollEnd) that.options.onBeforeScrollEnd.call(that, e);
if(that.zoomed){
scale=that.scale * that.lastScale;
scale=Math.max(that.options.zoomMin, scale);
scale=Math.min(that.options.zoomMax, scale);
that.lastScale=scale / that.scale;
that.scale=scale;
that.x=that.originX - that.originX * that.lastScale + that.x;
that.y=that.originY - that.originY * that.lastScale + that.y;
that.scroller.style[transitionDuration]='200ms';
that.scroller.style[transform]='translate(' + that.x + 'px,' + that.y + 'px) scale(' + that.scale + ')' + translateZ;
that.zoomed=false;
that.refresh();
if(that.options.onZoomEnd) that.options.onZoomEnd.call(that, e);
return;
}
if(!that.moved){
if(hasTouch){
if(that.doubleTapTimer&&that.options.zoom){
clearTimeout(that.doubleTapTimer);
that.doubleTapTimer=null;
if(that.options.onZoomStart) that.options.onZoomStart.call(that, e);
that.zoom(that.pointX, that.pointY, that.scale==1 ? that.options.doubleTapZoom:1);
if(that.options.onZoomEnd){
setTimeout(function(){
that.options.onZoomEnd.call(that, e);
}, 200);
}}else if(this.options.handleClick){
that.doubleTapTimer=setTimeout(function (){
that.doubleTapTimer=null;
target=point.target;
while (target.nodeType!=1) target=target.parentNode;
if(target.tagName!='SELECT'&&target.tagName!='INPUT'&&target.tagName!='TEXTAREA'){
ev=doc.createEvent('MouseEvents');
ev.initMouseEvent('click', true, true, e.view, 1,
point.screenX, point.screenY, point.clientX, point.clientY,
e.ctrlKey, e.altKey, e.shiftKey, e.metaKey,
0, null);
ev._fake=true;
target.dispatchEvent(ev);
}}, that.options.zoom ? 250:0);
}}
that._resetPos(400);
if(that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
return;
}
if(duration < 300&&that.options.momentum){
momentumX=newPosX ? that._momentum(newPosX - that.startX, duration, -that.x, that.scrollerW - that.wrapperW + that.x, that.options.bounce ? that.wrapperW:0):momentumX;
momentumY=newPosY ? that._momentum(newPosY - that.startY, duration, -that.y, (that.maxScrollY < 0 ? that.scrollerH - that.wrapperH + that.y - that.minScrollY:0), that.options.bounce ? that.wrapperH:0):momentumY;
newPosX=that.x + momentumX.dist;
newPosY=that.y + momentumY.dist;
if((that.x > 0&&newPosX > 0)||(that.x < that.maxScrollX&&newPosX < that.maxScrollX)) momentumX={ dist:0, time:0 };
if((that.y > that.minScrollY&&newPosY > that.minScrollY)||(that.y < that.maxScrollY&&newPosY < that.maxScrollY)) momentumY={ dist:0, time:0 };}
if(momentumX.dist||momentumY.dist){
newDuration=m.max(m.max(momentumX.time, momentumY.time), 10);
if(that.options.snap){
distX=newPosX - that.absStartX;
distY=newPosY - that.absStartY;
if(m.abs(distX) < that.options.snapThreshold&&m.abs(distY) < that.options.snapThreshold){ that.scrollTo(that.absStartX, that.absStartY, 200); }else{
snap=that._snap(newPosX, newPosY);
newPosX=snap.x;
newPosY=snap.y;
newDuration=m.max(snap.time, newDuration);
}}
that.scrollTo(m.round(newPosX), m.round(newPosY), newDuration);
if(that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
return;
}
if(that.options.snap){
distX=newPosX - that.absStartX;
distY=newPosY - that.absStartY;
if(m.abs(distX) < that.options.snapThreshold&&m.abs(distY) < that.options.snapThreshold) that.scrollTo(that.absStartX, that.absStartY, 200);
else {
snap=that._snap(that.x, that.y);
if(snap.x!=that.x||snap.y!=that.y) that.scrollTo(snap.x, snap.y, snap.time);
}
if(that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
return;
}
that._resetPos(200);
if(that.options.onTouchEnd) that.options.onTouchEnd.call(that, e);
},
_resetPos: function (time){
var that=this,
resetX=that.x >=0 ? 0:that.x < that.maxScrollX ? that.maxScrollX:that.x,
resetY=that.y >=that.minScrollY||that.maxScrollY > 0 ? that.minScrollY:that.y < that.maxScrollY ? that.maxScrollY:that.y;
if(resetX==that.x&&resetY==that.y){
if(that.moved){
that.moved=false;
if(that.options.onScrollEnd) that.options.onScrollEnd.call(that);
}
if(that.hScrollbar&&that.options.hideScrollbar){
if(vendor=='webkit') that.hScrollbarWrapper.style[transitionDelay]='300ms';
that.hScrollbarWrapper.style.opacity='0';
}
if(that.vScrollbar&&that.options.hideScrollbar){
if(vendor=='webkit') that.vScrollbarWrapper.style[transitionDelay]='300ms';
that.vScrollbarWrapper.style.opacity='0';
}
return;
}
that.scrollTo(resetX, resetY, time||0);
},
_wheel: function (e){
var that=this,
wheelDeltaX, wheelDeltaY,
deltaX, deltaY,
deltaScale;
if('wheelDeltaX' in e){
wheelDeltaX=e.wheelDeltaX / 12;
wheelDeltaY=e.wheelDeltaY / 12;
}else if('wheelDelta' in e){
wheelDeltaX=wheelDeltaY=e.wheelDelta / 12;
}else if('detail' in e){
wheelDeltaX=wheelDeltaY=-e.detail * 3;
}else{
return;
}
if(that.options.wheelAction=='zoom'){
deltaScale=that.scale * Math.pow(2, 1/3 * (wheelDeltaY ? wheelDeltaY / Math.abs(wheelDeltaY):0));
if(deltaScale < that.options.zoomMin) deltaScale=that.options.zoomMin;
if(deltaScale > that.options.zoomMax) deltaScale=that.options.zoomMax;
if(deltaScale!=that.scale){
if(!that.wheelZoomCount&&that.options.onZoomStart) that.options.onZoomStart.call(that, e);
that.wheelZoomCount++;
that.zoom(e.pageX, e.pageY, deltaScale, 400);
setTimeout(function(){
that.wheelZoomCount--;
if(!that.wheelZoomCount&&that.options.onZoomEnd) that.options.onZoomEnd.call(that, e);
}, 400);
}
return;
}
deltaX=that.x + wheelDeltaX;
deltaY=that.y + wheelDeltaY;
if(deltaX > 0) deltaX=0;
else if(deltaX < that.maxScrollX) deltaX=that.maxScrollX;
if(deltaY > that.minScrollY) deltaY=that.minScrollY;
else if(deltaY < that.maxScrollY) deltaY=that.maxScrollY;
if(that.maxScrollY < 0){
that.scrollTo(deltaX, deltaY, 0);
}},
_transitionEnd: function (e){
var that=this;
if(e.target!=that.scroller) return;
that._unbind(TRNEND_EV);
that._startAni();
},
_startAni: function (){
var that=this,
startX=that.x, startY=that.y,
startTime=Date.now(),
step, easeOut,
animate;
if(that.animating) return;
if(!that.steps.length){
that._resetPos(400);
return;
}
step=that.steps.shift();
if(step.x==startX&&step.y==startY) step.time=0;
that.animating=true;
that.moved=true;
if(that.options.useTransition){
that._transitionTime(step.time);
that._pos(step.x, step.y);
that.animating=false;
if(step.time) that._bind(TRNEND_EV);
else that._resetPos(0);
return;
}
animate=function (){
var now=Date.now(),
newX, newY;
if(now >=startTime + step.time){
that._pos(step.x, step.y);
that.animating=false;
if(that.options.onAnimationEnd) that.options.onAnimationEnd.call(that);
that._startAni();
return;
}
now=(now - startTime) / step.time - 1;
easeOut=m.sqrt(1 - now * now);
newX=(step.x - startX) * easeOut + startX;
newY=(step.y - startY) * easeOut + startY;
that._pos(newX, newY);
if(that.animating) that.aniTime=nextFrame(animate);
};
animate();
},
_transitionTime: function (time){
time +='ms';
this.scroller.style[transitionDuration]=time;
if(this.hScrollbar) this.hScrollbarIndicator.style[transitionDuration]=time;
if(this.vScrollbar) this.vScrollbarIndicator.style[transitionDuration]=time;
},
_momentum: function (dist, time, maxDistUpper, maxDistLower, size){
var deceleration=0.0006,
speed=m.abs(dist) / time,
newDist=(speed * speed) / (2 * deceleration),
newTime=0, outsideDist=0;
if(dist > 0&&newDist > maxDistUpper){
outsideDist=size / (6 / (newDist / speed * deceleration));
maxDistUpper=maxDistUpper + outsideDist;
speed=speed * maxDistUpper / newDist;
newDist=maxDistUpper;
}else if(dist < 0&&newDist > maxDistLower){
outsideDist=size / (6 / (newDist / speed * deceleration));
maxDistLower=maxDistLower + outsideDist;
speed=speed * maxDistLower / newDist;
newDist=maxDistLower;
}
newDist=newDist * (dist < 0 ? -1:1);
newTime=speed / deceleration;
return { dist: newDist, time: m.round(newTime) };},
_offset: function (el){
var left=-el.offsetLeft,
top=-el.offsetTop;
while (el=el.offsetParent){
left -=el.offsetLeft;
top -=el.offsetTop;
}
if(el!=this.wrapper){
left *=this.scale;
top *=this.scale;
}
return { left: left, top: top };},
_snap: function (x, y){
var that=this,
i, l,
page, time,
sizeX, sizeY;
page=that.pagesX.length - 1;
for (i=0, l=that.pagesX.length; i
=that.pagesX[i]){
page=i;
break;
}}
if(page==that.currPageX&&page > 0&&that.dirX < 0) page--;
x=that.pagesX[page];
sizeX=m.abs(x - that.pagesX[that.currPageX]);
sizeX=sizeX ? m.abs(that.x - x) / sizeX * 500:0;
that.currPageX=page;
page=that.pagesY.length-1;
for (i=0; i=that.pagesY[i]){
page=i;
break;
}}
if(page==that.currPageY&&page > 0&&that.dirY < 0) page--;
y=that.pagesY[page];
sizeY=m.abs(y - that.pagesY[that.currPageY]);
sizeY=sizeY ? m.abs(that.y - y) / sizeY * 500:0;
that.currPageY=page;
time=m.round(m.max(sizeX, sizeY))||200;
return { x: x, y: y, time: time };},
_bind: function (type, el, bubble){
(el||this.scroller).addEventListener(type, this, !!bubble);
},
_unbind: function (type, el, bubble){
(el||this.scroller).removeEventListener(type, this, !!bubble);
},
destroy: function (){
var that=this;
that.scroller.style[transform]='';
that.hScrollbar=false;
that.vScrollbar=false;
that._scrollbar('h');
that._scrollbar('v');
that._unbind(RESIZE_EV, window);
that._unbind(START_EV);
that._unbind(MOVE_EV, window);
that._unbind(END_EV, window);
that._unbind(CANCEL_EV, window);
if(!that.options.hasTouch){
that._unbind('DOMMouseScroll');
that._unbind('mousewheel');
}
if(that.options.useTransition) that._unbind(TRNEND_EV);
if(that.options.checkDOMChanges) clearInterval(that.checkDOMTime);
if(that.options.onDestroy) that.options.onDestroy.call(that);
},
refresh: function (){
var that=this,
offset,
i, l,
els,
pos=0,
page=0;
if(that.scale < that.options.zoomMin) that.scale=that.options.zoomMin;
that.wrapperW=that.wrapper.clientWidth||1;
that.wrapperH=that.wrapper.clientHeight||1;
that.minScrollY=-that.options.topOffset||0;
that.scrollerW=m.round(that.scroller.offsetWidth * that.scale);
that.scrollerH=m.round((that.scroller.offsetHeight + that.minScrollY) * that.scale);
that.maxScrollX=that.wrapperW - that.scrollerW;
that.maxScrollY=that.wrapperH - that.scrollerH + that.minScrollY;
that.dirX=0;
that.dirY=0;
if(that.options.onRefresh) that.options.onRefresh.call(that);
that.hScroll=that.options.hScroll&&that.maxScrollX < 0;
that.vScroll=that.options.vScroll&&(!that.options.bounceLock&&!that.hScroll||that.scrollerH > that.wrapperH);
that.hScrollbar=that.hScroll&&that.options.hScrollbar;
that.vScrollbar=that.vScroll&&that.options.vScrollbar&&that.scrollerH > that.wrapperH;
offset=that._offset(that.wrapper);
that.wrapperOffsetLeft=-offset.left;
that.wrapperOffsetTop=-offset.top;
if(typeof that.options.snap=='string'){
that.pagesX=[];
that.pagesY=[];
els=that.scroller.querySelectorAll(that.options.snap);
for (i=0, l=els.length; i=that.maxScrollX){
that.pagesX[page]=pos;
pos=pos - that.wrapperW;
page++;
}
if(that.maxScrollX%that.wrapperW) that.pagesX[that.pagesX.length]=that.maxScrollX - that.pagesX[that.pagesX.length-1] + that.pagesX[that.pagesX.length-1];
pos=0;
page=0;
that.pagesY=[];
while (pos >=that.maxScrollY){
that.pagesY[page]=pos;
pos=pos - that.wrapperH;
page++;
}
if(that.maxScrollY%that.wrapperH) that.pagesY[that.pagesY.length]=that.maxScrollY - that.pagesY[that.pagesY.length-1] + that.pagesY[that.pagesY.length-1];
}
that._scrollbar('h');
that._scrollbar('v');
if(!that.zoomed){
that.scroller.style[transitionDuration]='0';
that._resetPos(400);
}},
scrollTo: function (x, y, time, relative){
var that=this,
step=x,
i, l;
that.stop();
if(!step.length) step=[{ x: x, y: y, time: time, relative: relative }];
for (i=0, l=step.length; i 0 ? 0:pos.left < that.maxScrollX ? that.maxScrollX:pos.left;
pos.top=pos.top > that.minScrollY ? that.minScrollY:pos.top < that.maxScrollY ? that.maxScrollY:pos.top;
time=time===undefined ? m.max(m.abs(pos.left)*2, m.abs(pos.top)*2):time;
that.scrollTo(pos.left, pos.top, time);
},
scrollToPage: function (pageX, pageY, time){
var that=this, x, y;
time=time===undefined ? 400:time;
if(that.options.onScrollStart) that.options.onScrollStart.call(that);
if(that.options.snap){
pageX=pageX=='next' ? that.currPageX+1:pageX=='prev' ? that.currPageX-1:pageX;
pageY=pageY=='next' ? that.currPageY+1:pageY=='prev' ? that.currPageY-1:pageY;
pageX=pageX < 0 ? 0:pageX > that.pagesX.length-1 ? that.pagesX.length-1:pageX;
pageY=pageY < 0 ? 0:pageY > that.pagesY.length-1 ? that.pagesY.length-1:pageY;
that.currPageX=pageX;
that.currPageY=pageY;
x=that.pagesX[pageX];
y=that.pagesY[pageY];
}else{
x=-that.wrapperW * pageX;
y=-that.wrapperH * pageY;
if(x < that.maxScrollX) x=that.maxScrollX;
if(y < that.maxScrollY) y=that.maxScrollY;
}
that.scrollTo(x, y, time);
},
disable: function (){
this.stop();
this._resetPos(0);
this.enabled=false;
this._unbind(MOVE_EV, window);
this._unbind(END_EV, window);
this._unbind(CANCEL_EV, window);
},
enable: function (){
this.enabled=true;
},
stop: function (){
if(this.options.useTransition) this._unbind(TRNEND_EV);
else cancelFrame(this.aniTime);
this.steps=[];
this.moved=false;
this.animating=false;
},
zoom: function (x, y, scale, time){
var that=this,
relScale=scale / that.scale;
if(!that.options.useTransform) return;
that.zoomed=true;
time=time===undefined ? 200:time;
x=x - that.wrapperOffsetLeft - that.x;
y=y - that.wrapperOffsetTop - that.y;
that.x=x - x * relScale + that.x;
that.y=y - y * relScale + that.y;
that.scale=scale;
that.refresh();
that.x=that.x > 0 ? 0:that.x < that.maxScrollX ? that.maxScrollX:that.x;
that.y=that.y > that.minScrollY ? that.minScrollY:that.y < that.maxScrollY ? that.maxScrollY:that.y;
that.scroller.style[transitionDuration]=time + 'ms';
that.scroller.style[transform]='translate(' + that.x + 'px,' + that.y + 'px) scale(' + scale + ')' + translateZ;
that.zoomed=false;
},
isReady: function (){
return !this.moved&&!this.zoomed&&!this.animating;
}};
function prefixStyle (style){
if(vendor==='') return style;
style=style.charAt(0).toUpperCase() + style.substr(1);
return vendor + style;
}
dummyStyle=null;
if(typeof exports!=='undefined') exports.iScroll=iScroll;
else window.iScroll=iScroll;
})(window, document);
jQuery(document).ready(function($){
var isTouch=false,
click_event='click';
if(jQuery('html').hasClass('touch')){
isTouch=true,
click_event='click';
}
var $fullsize=jQuery('#fullsize'),
$scrollerItems=jQuery('#fullsize .item'),
$cntItems=$scrollerItems.length,
$fullsizeTimer=jQuery('#fullsizeTimer'),
$fullsizeStart=jQuery('#fullsizeStart'),
$fullsizeStop=jQuery('#fullsizeStop'),
$togthumbs=jQuery('#toggleThumbnails'),
$thumbContainer=jQuery('#thumbnailContainer'),
$colophon=jQuery('#colophon'),
thumbs_array=jQuery('#thumbnailContainer').find('a');
window.thumbnailsLoaded=false;
jQuery.fn.stopTimer=function(){
if(!Modernizr.csstransitions){
jQuery(this).stop().width(0);
}else{
jQuery(this).attr('style', '');
}}
jQuery.fn.startTimer=function(timer, resume){
var elem=jQuery(this);
if(resume){
var left_duration=timer *(jQuery(window).width() - elem.width()) / jQuery(window).width();
jQuery.fn.superbgimage.options.slide_interval=left_duration;
elem.stop(true).animate({
width: jQuery(window).width()
}, {
duration: left_duration,
specialEasing: {
width: "linear"
}});
}else{
if(jQuery.fn.superbgimage.options.slideshow==1||(jQuery('#superbgimageplayer').hasClass('jwplayer_init')&&jwplayer('superbgimageplayer').getState()=="PLAYING")){
$actItem=jQuery('#fullsize .item.activeslide');
$ind=jQuery('a.activeslide').index("#fullsize .item") + 1;
if($ind==1){
$fullsize.animate({ marginLeft: 0 });
}
if(!Modernizr.csstransitions){
elem.css({ width: 0 }).stop(true).animate({
width: "100%"
}, {
duration: timer,
specialEasing: {
width: "linear"
}});
}else{
elem.css({ 'transition-duration': timer + "ms", width: "100%" });
}}
}};
jQuery.fn.pauseTimer=function(timer){
jQuery(this).stop(true);
$fullsizeStart.show();
$fullsizeStop.hide();
}
if(jQuery('#thumbnails').hasClass('centered')){
jQuery('#thumbnails .controls').css({ right: 50 + "%", marginRight: -jQuery('#thumbnails .controls').outerWidth() / 2 });
}
jQuery('#fullsize .overlay').on('touchstart touchend', function(e){
e.preventDefault();
jQuery(this).toggleClass('overlay-visible');
});
jQuery('#fullsize a').on('mouseover mouseout', '.overlay', function(e){
jQuery(this).toggleClass('overlay-visible');
})
jQuery(window).on('load', function(){
setScrollerWidth(thumbs_array, 0);
var images_to_load=jQuery('a.item img:not(img.loaded)', $fullsize);
if(images_to_load.length){
images_to_load.each(function(){
var a=jQuery(this).parent();
if(a.position().left - a.width() <=$thumbContainer.width()){
var img=jQuery(this);
img.attr('src', img.data('src')).addClass('loaded')
}});
}
var anim_height=jQuery('#thumbnails').outerHeight(true) + $colophon.outerHeight(true);
var scrollPane=jQuery("#thumbnailContainer"),
scrollContent=$fullsize;
var slide_handler=function(e, ui){
if(scrollContent.width() > scrollPane.width()){
var scroll_margin=ui.value / 100 *(scrollPane.width() - scrollContent.width());
scrollContent.css("margin-left", Math.round(scroll_margin) + "px");
jQuery('a.item img:not(img.loaded)', $fullsize).each(function(){
var img=jQuery(this);
img.not('img.loaded').attr('src', img.data('src')).addClass('loaded')
});
setScrollerWidth(thumbs_array, 0);
}else{
scrollContent.css("margin-left", 0);
}};
var scrollbar=jQuery(".scroll-bar").slider({
slide: slide_handler,
change: slide_handler
});
jQuery('.scroll-content-item:last').css({marginRight: 0});
if(!isTouch){
if(!jQuery('#thumbnails').hasClass('mouse-scrub')){
scrollPane.mousewheel(function(event, delta){
var value=scrollbar.slider('option', 'value');
if(delta > 0){ value -=1.25; }
else if(delta < 0){ value +=1.25; }
value=Math.max(0, Math.min(100, value));
scrollbar.slider('option', 'value', value);
event.preventDefault();
});
}
jQuery("#scroll_right").on('mouseover', function(){
timer=setInterval(function(){
jQuery("#scroll_left").removeClass('disabled');
var speed=parseInt(2);
var slider=jQuery('.scroll-bar');
var curSlider=slider.slider("option", "value");
curSlider +=speed;
if(curSlider > slider.slider("option", "max")){
jQuery("#scroll_right").addClass('disabled');
curSlider=slider.slider("option", "max");
}else if(curSlider < slider.slider("option", "min")){
curSlider=slider.slider("option", "min");
}else{
}
slider.slider("value", curSlider);
}, 25);
});
jQuery("#scroll_right").on('mouseout', function(){
clearInterval(timer);
});
jQuery("#scroll_left").on('mouseover', function(){
timer=setInterval(function(){
jQuery("#scroll_right").removeClass('disabled');
var speed=parseInt(2);
var slider=jQuery('.scroll-bar');;
var curSlider=slider.slider("option", "value");
curSlider -=speed;
if(curSlider > slider.slider("option", "max")){
curSlider=slider.slider("option", "max");
}else if(curSlider < slider.slider("option", "min")){
jQuery("#scroll_left").addClass('disabled');
curSlider=slider.slider("option", "min");
}
slider.slider("value", curSlider);
}, 25);
});
jQuery("#scroll_left").on('mouseout', function(){
clearInterval(timer);
});
}});
function setScrollerWidth(elements, original, return_only){
var contWidth=original;
elements.each(function(){
contWidth=contWidth + jQuery(this).outerWidth(true);
})
if(return_only){
return contWidth;
}
if(contWidth > jQuery('#thumbnails').width()){
jQuery('#thumbnails .pulldown-items').width(contWidth);
if(!isTouch) jQuery('#thumbnails .scroll-link').addClass('scroll-visible');
}else{
if(!isTouch) jQuery('#thumbnails .scroll-link').removeClass('scroll-visible')
jQuery('#thumbnails .pulldown-items').css("margin-left", 0);
}
var origWidth=jQuery(".scroll-bar").width();
var sliderWidth=origWidth - 200;
var sliderMargin=(origWidth - sliderWidth)*0.5;
jQuery(".scroll-bar-wrap").css({ width:sliderWidth, marginRight: sliderMargin });
}
jQuery(window).smartresize(function(){
var contWidth=setScrollerWidth(thumbs_array, 0, true);
if(contWidth > jQuery('#thumbnails').width()){
jQuery('#thumbnails .pulldown-items').width(contWidth);
if(!isTouch) jQuery('#thumbnails .scroll-link').addClass('scroll-visible');
}else{
if(!isTouch) jQuery('#thumbnails .scroll-link').removeClass('scroll-visible')
jQuery('#thumbnails .pulldown-items').css("margin-left", 0);
}
var images_to_load=jQuery('a.item img:not(img.loaded)', $fullsize);
if(images_to_load.length){
images_to_load.each(function(){
var img=jQuery(this);
img.not('img.loaded').attr('src', img.data('src')).addClass('loaded')
});
setScrollerWidth(thumbs_array, 0);
}
if(isTouch){
myScrollRefresh();
}});
$fullsize.superbgimage();
var fullsizePrev=jQuery('#thumbnails a.fullsize-prev, .fsg-arrows a.fsg-arrows-prev').livequery(click_event,function(e){
perform_prevAnimation($fullsize, $fullsizeTimer);
e.preventDefault();
return false;
});
if(jQuery().swipe){
jQuery.fn.addFullsizeTouchswipe=function(){
jQuery(this).swipe({
threshold: 50,
swipe: function(event, direction, distance, duration, fingerCount){
if(fingerCount==1){
if('left'===direction){
perform_nextAnimation();
}
if('right'===direction){
perform_prevAnimation($fullsize, $fullsizeTimer);
}
if('down'===direction){
$togthumbs.toggleThumbnails('hide', true);
}
if('up'===direction){
$togthumbs.toggleThumbnails('show', true);
}}
if(fingerCount==2){
if('up'===direction&&true===window.allElementsVisible){
$expander.hideAllElements('hide', 1);
}
if('down'===direction&&false===window.allElementsVisible){
$expander.hideAllElements('show', 1);
}}
},
fingers: 'all',
allowPageScroll: 'none'
});
};
if(isTouch){
jQuery("#superbgimage, #scanlines, #page").swipe("destroy");
jQuery("#superbgimage, #scanlines, #page").addFullsizeTouchswipe();
}}
function perform_prevAnimation($fullsize, $fullsizeTimer){
jQuery('#superbgimageplayer').html();
jQuery('#startInterval').val("start");
$fullsizeTimer.stopTimer();
$fullsize.prevSlide();
if(jQuery.fn.superbgimage.options.slideshow==1){
$fullsize.startSlideShow();
}else{
$fullsize.stopSlideShow();
}}
var fullsizeNext=jQuery('#thumbnails a.fullsize-next, .fsg-arrows a.fsg-arrows-next').livequery(click_event,function(){
perform_nextAnimation();
return false;
});
function perform_nextAnimation(){
jQuery('#superbgimageplayer').html();
jQuery('#startInterval').val("start");
$fullsizeTimer.stopTimer();
$fullsize.nextSlide();
if(jQuery.fn.superbgimage.options.slideshow==1){
$fullsize.startSlideShow();
}else{
$fullsize.stopSlideShow();
}}
if(jQuery('#thumbnails').hasClass('mouse-scrub')){
var div=jQuery('#thumbnailContainer'),
ul=jQuery('#fullsize'),
ulPadding=15;
div.css({overflow: 'hidden'});
var lastLi=jQuery('a',ul).filter(":last");
div.mousemove(function(e){
var divWidth=div.width();
var ulWidth=lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;
var left=(e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
div.scrollLeft(left);
var images_to_load=jQuery('a.item img:not(img.loaded)', $fullsize);
if(images_to_load.length){
images_to_load.each(function(){
var img=jQuery(this);
img.not('img.loaded').attr('src', img.data('src')).addClass('loaded')
});
setScrollerWidth(thumbs_array, 0);
}});
}
if(jQuery('#thumbnails').hasClass('key-nav')&&jQuery('a.item', $fullsize).size() > 1){
jQuery(document).keydown(function (e){
var keyCode=e.keyCode||e.which,
arrow={left: 37, up: 38, space: 32, right: 39, down: 40 };
switch (keyCode){
case arrow.left:
perform_prevAnimation($fullsize, $fullsizeTimer);
break;
case arrow.up:
$togthumbs.toggleThumbnails('show', true);
break;
case arrow.right:
perform_nextAnimation();
break;
case arrow.down:
$togthumbs.toggleThumbnails('hide', true);
break;
case arrow.space:
jQuery('#thumbnails .controls').livequery(function(){
if(jQuery(this).hasClass('fullsize-playing')){
jQuery.fn.superbgimage.options.slideshow=0;
$fullsizetimer.stopTimer();
jQuery('#fullsize').stopSlideShow();
jQuery(this).toggleClass('fullsize-playing');
}else{
jQuery.fn.superbgimage.options.slideshow=1;
jQuery(this).toggleClass('fullsize-playing');
jQuery.fn.superbgimage.options.slide_interval=jQuery('#thumbnails').data('object').fullsize_interval;
$fullsizetimer.startTimer(jQuery('#thumbnails').data('object').fullsize_interval);
$fullsize.startSlideShow();
}})
break;
}});
}else{
jQuery('#fullsizeKeynav').hide();
}
if(jQuery('#thumbnails').hasClass('mouse-leave')){
jQuery('#colophon, #thumbnails').on('mouseenter', function(e){
var thumbnails=jQuery('#thumbnails'),
fotBot=parseInt($colophon.css('bottom')),
botAni=$colophon.outerHeight();
if(fotBot < 0||$colophon.hasClass('footer-hide')){
botAni=0;
}
if(!Modernizr.csstransitions){
thumbnails.stop().animate({ bottom: botAni });
}else{
thumbnails.removeClass('thumbs-collapsed').css({ bottom: 0, 'transform': 'translate3d(0, ' + botAni * - 1 + 'px, 0)' });
}});
jQuery('#thumbnails').on('mouseleave', function(e){
var thumbnails=jQuery('#thumbnails'),
fotBot=parseInt($colophon.css('bottom')),
botAni=$colophon.outerHeight();
if(fotBot < 0||$colophon.hasClass('footer-hide')){
botAni=0;
}
if(!Modernizr.csstransitions){
thumbnails.stop().animate({ bottom: -thumbnails.outerHeight() + botAni + thumbnails.find('.controls').outerHeight() });
}else{
var translateY=thumbnails.outerHeight(true) - parseInt(thumbnails.css('padding-top'), 10) - botAni;
thumbnails.addClass('thumbs-collapsed').css({ bottom: 0, 'transform': 'translate3d(0, '+ (translateY) +'px, 0)' });
}});
}
if(isTouch){
if(jQuery('#thumbnailContainer').length){
var myScroll;
function myScrollLoaded(){
setTimeout(function (){
myScroll=new iScroll('thumbnailContainer', {
hScrollbar: false,
vScrollbar: false,
vScroll: false,
onBeforeScrollMove: function(){
jQuery('#fullsize .overlay').show();
},
onTouchEnd:function(){
jQuery('#fullsize .overlay').hide();
var images_to_load=jQuery('a.item img:not(img.loaded)', $fullsize);
if(images_to_load.length){
images_to_load.each(function(){
var img=jQuery(this);
img.not('img.loaded').attr('src', img.data('src')).addClass('loaded')
});
}
setScrollerWidth(thumbs_array, 0);
}});
}, 100);
}
document.addEventListener('touchmove', function (e){ e.preventDefault(); }, false);
window.addEventListener('load', myScrollLoaded, false);
function myScrollRefresh(){
setTimeout(function(){
myScroll.refresh();
}, 0);
};}}
});
!function(a,b){"use strict";function c(){if(!e){e=!0;var a,c,d,f,g=-1!==navigator.appVersion.indexOf("MSIE 10"),h=!!navigator.userAgent.match(/Trident.*rv:11\./),i=b.querySelectorAll("iframe.wp-embedded-content");for(c=0;c1e3)g=1e3;else if(~~g<200)g=200;f.height=g}if("link"===d.message)if(h=b.createElement("a"),i=b.createElement("a"),h.href=f.getAttribute("src"),i.href=d.value,i.host===h.host)if(b.activeElement===f)a.top.location.href=d.value}else;}},d)a.addEventListener("message",a.wp.receiveEmbedMessage,!1),b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",c,!1)}(window,document);